const Router = require('koa-router')
const {RegisterValidator} = require('../../validator/vilidator')
const {User} = require('../../models/user')

const router = new Router({
  prefix: '/v1/user'
})

router.post('/register', async (ctx) => {
  const v = await new RegisterValidator().validate(ctx)
  
  const user = {
    nickname: v.get('body.nickname'),
    email: v.get('body.email'),
    password: v.get('body.password2')
  }
  User.create(user)
  throw new global.errs.Success()
})


module.exports = router